<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="24">
            <a-form-model-item label="档案名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="archiveName">
              <a-input :disabled=formDisabled v-model="model.archiveName" :max-length="36"  placeholder="请输入档案名称"  ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="纸质版数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="paperVersionQuantity">
<!--              <a-input :disabled=formDisabled v-model="model.paperVersionQuantity" :max-length="36"  placeholder="请输入纸质版数量"  ></a-input>-->
              <a-input-number :disabled=formDisabled :max="999999999" :min="0" :precision="0" v-model="model.paperVersionQuantity" placeholder="请输入纸质版数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="是否有电子版" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="isElectronicVersion">
<!--              <a-input :disabled=formDisabled v-model="model.isElectronicVersion" :max-length="36"  placeholder="请输入是否有电子版"  ></a-input>-->
              <j-dict-select-tag :disabled=formDisabled type="radio" v-model="model.isElectronicVersion" dictCode="yes_no" placeholder="是否有电子版" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-textarea :maxLength="500" :disabled="formDisabled" v-model="model.remark" rows="4" placeholder="请输入备注"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

  import { httpAction, getAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
  import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
  import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
  import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
  import moment from 'moment'
  import { mapGetters } from 'vuex'

  export default {
    name: 'ErpProjectArchiveInfoForm',
    components: {
      SelectUserByDep,
      SelectTeamInput,
      SelectCompanyInput,
      SelectCustomerInput
    },
    props: {
      //表单禁用
      disabled: {
        type: Boolean,
        default: false,
        required: false
      }
    },
    data() {
      return {
        model:{
         },
        labelCol: {
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 24 },
        },
        confirmLoading: false,
        validatorRules: {
          archiveName: [
            { required: true, message: '请输入档案名称!' },
          ],
          paperVersionQuantity: [
            { required: true, message: '请输入纸质版数量!' },
          ],
          isElectronicVersion: [
            { required: true, message: '请选择是否有电子版!' },
          ],
        },
        url: {
          add: "/api/erp/omc/projectarchive/erpProjectArchiveInfo/add",
          edit: "/api/erp/omc/projectarchive/erpProjectArchiveInfo/edit",
          queryById: "/api/erp/omc/projectarchive/erpProjectArchiveInfo/queryById"
        },
        flag: false,
      }
    },
    computed: {
      formDisabled(){
        return this.disabled
      },
    },
    created () {
       //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      ...mapGetters(['userInfo']),
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.$refs.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      submitForm () {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            // this.$emit("ok",this.model);
            let data = JSON.stringify(that.model)
            that.$emit('ok', JSON.parse(data), that.flag);
          }
        })
      },
    }
  }
</script>
